<!--#INCLUDE FILE="config.asp"-->
<%
if(session("CostabajaId") = "" and Session("CostabajaAccessLevel") <> 2 ) then
	Response.Redirect("default.asp?msg=invalid")
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../styles.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<!-- DATE PICKER SCRIPT -->
<link type="text/css" href="../css/jquery-ui-1.8.21.custom.css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../js/jquery-ui-1.8.21.custom.min.js"></script>
<script>
	$(function() {
		$('.aprovar').unbind();
		$('.aprovar').click(function() { 
		
			var buttonId = $(this).attr('id');
			var numberTravel = buttonId.substring("AprovarF_".length+1);
			var approveId = buttonId.substring("AprovarF_".length-2);
			
			// check reservation textbox <> empty
			if ($("#reservation"+approveId).val() == '')
			{
				alert('please input value to reservation');
				$("#reservation"+approveId).focus();
				return false;
			}
			
			var remainingNumberButton = 1;
			var numberButton = buttonId.substring(8,9);
			if (numberButton == 1)
				remainingNumberButton = 2; 
			$.ajax({
				type:"GET",
				url: "approve_process.asp",
				dataType: "html",
				data: {
					GuesId: $("#guesId").val(),
					reservationCode:$("#reservation"+approveId).val(), 
					actualArrival:$("#arrival"+approveId).val(),
					actualDeparture:$("#departure"+approveId).val(),
					travelId:$("#travelID_"+numberTravel).val()
				},
				async: false,
				success: function(data){ 
					$("#Aprovar"+approveId).val('Aprovado');
					$("#Aprovar"+approveId).attr("disabled", "true");
					$("#AprovarF"+remainingNumberButton+"_"+numberTravel).val('anulado');
					$("#AprovarF"+remainingNumberButton+"_"+numberTravel).attr("disabled", "true");
					$("#travelID_"+numberTravel).val('');
				},
				error: function(){
					alert('error');
				}
			});
			return false;
		
		});
		
		
	});
	</script>
  <!-- END DATE PICKER SCRIPT -->
  
  <script> 
  $(document).ready(function(){
  $('ul.guest_timeline_list li:nth-child(odd)').addClass('alternate');
});
</script>


<title>Pendiente por Aprovacion :: Costa Baja</title>

</head>
<body>
<%
	if(request("gId") <> "") then
		guestID = request("gId")
	else 
		guestID = 0
	end if
	
	sqlstring = ""
	sqlstring = sqlstring & "SELECT Guests.*, Travels.*"
	sqlstring = sqlstring & "FROM Guests "
	sqlstring = sqlstring & "INNER JOIN Guests_Travels on Guests.GuestID = Guests_Travels.GuestID "
	sqlstring = sqlstring & "INNER JOIN Travels on Guests_Travels.TravelID = Travels.TravelID "
	sqlstring = sqlstring & "WHERE Guests.GuestID ="& guestID
	
	set objConnect = server.createObject("ADODB.Connection")   

	objConnect.Open conStr

	set TblTemp = server.createobject("Adodb.Recordset")
	
	TblTemp.Open sqlstring, objConnect
	
	dim count
	
	dim travelsAreals, strItem
	SET travelsAreals = CreateObject("Scripting.Dictionary")
	count = 0
	Do Until TblTemp.EOF
		count = count + 1
			Travelid = TblTemp("TravelID")
			Name = TblTemp("Name")
			Middle = TblTemp("Middle")
			Surname = TblTemp("Surname")
			TotalNumberGuests = TblTemp("TotalNumberGuests")
			NumberChildren = TblTemp("NumberChildren")
			ExtraNight = TblTemp("ExtraNight")
			status = TblTemp("StatusID")
			
			travelsAreals.Add ""&count, Array(TotalNumberGuests,NumberChildren,ExtraNight,Travelid,status)	
	TblTemp.MoveNext
	Loop
%>
<div id="main_wrapper">
    	<div class="main_wrapper_margin">
        	
            <div class="admin_top_menu">
            <!--#INCLUDE FILE="costabaja_menu.asp"--> 
           	</div>
        
    		<h1>Pendiente por Aprovacion: <%=Name &" "&Surname%></h1>
         	<div class="clear"></div>
            
            <hr/>
           
  
 <form action="denied-process.asp" method="get">

<!-- SECOND PART OF THE FORM -->           
           <fieldset>
           		<legend>Informacion de Viaje </legend>
      
                  <table cellpadding="0" width="100%">
     	
<%
dim number
For Each strItem In travelsAreals
Do
If (travelsAreals(strItem)("4") <> 2) Then Exit Do
number = number + 1

		Dim x
		x = 0
		sqlstring5 = "SELECT * FROM Reservation WHERE TravelId = "&travelsAreals(strItem)("3")& " ORDER BY ActualArrival" 
		set TblTemp2 = server.createobject("Adodb.Recordset")
		
		TblTemp2.Open sqlstring5, objConnect
		Do Until TblTemp2.EOF
		x = x + 1
		
			ActualArrival = TblTemp2("ActualArrival")
			ActualDeparture = TblTemp2("ActualDeparture")
		
	%>       
                 <tr id="F<%=x%>_<%=number%>"> <!-- ROW -->
					<input type="hidden" id="travelID_<%=number%>" name="travelID_<%=number%>" value="<%=travelsAreals(strItem)("3")%>" />
                	<td width="33%">
            		<label>Fecha <%=x%></label>
  					</td>
                    <td width="33%">
                    <label>Llegada: </label><br />
                    <input type="text" id="arrivalF<%=x%>_<%=number%>" value="<%=ActualArrival%>" />
            		</td>
                    <td width="33%">
                    <label>Salida: </label><br />
					<input type="text" id="departureF<%=x%>_<%=number%>" value="<%=ActualDeparture%>" />
                    </td>
					<td width="33%">
                    <label>Reservation Code: </label><br />
					<input type="text" value="" id="reservationF<%=x%>_<%=number%>" />
                    </td>
                    <td align="left" valign="middle">
                   <input type="button" class="aprovar" value="Aprovar" id="AprovarF<%=x%>_<%=number%>" />
                    </td>
                </tr><!-- END ROW -->
                    
    <%
			TblTemp2.MoveNext
			Loop
		%>  
            
                <tr> <!-- ROW -->
                	<td width="33%">
            		<label>Numero Total de Invitados: </label><br />
                    <select>
                    <%For i = 0 To 5 %>
                    <option value="<%=i%>" <% if(travelsAreals(strItem)("0")= i) then%> selected="selected" <% end if%>><%=i%></option>
					<%Next%>                  
                    </select>
  					</td>
                    <td width="33%">
                    <label>Numero de Niños: </label><br />
                    <select>
                     <%For i = 0 To 10 %>
                    <option value="<%=i%>" <% if(travelsAreals(strItem)("1") = i) then%> selected="selected" <% end if%>><%=i%></option>
					<%Next%>                  
                    </select>
                    </td>
                    <td width="33%">
                    <label>Noches Extras: </label><br />
					<select>
                    <%For i = 0 To 5 %>
                    <option value="<%=i%>" <% if(travelsAreals(strItem)("2")= i) then%> selected="selected" <% end if%>><%=i%></option>
					<%Next%> 
                    </select>
                    </td>
                    
                    <td>&nbsp;
                    
                    </td>
                    
                </tr><!-- END ROW -->
				<tr><td colspan="4"><hr></td></tr>
          <%
		  Loop While False
	Next%>
	<input type="hidden" id="guesId" name="guesId" value="<%=guestID%>" />
	<input type="hidden" id="countTravel" name="countTravel" value="<%=travelsAreals.Count%>" />	          
<%IF (number <> 0) then%>               
			   <tr> <!-- ROW -->
                	<td width="33%">
                    <label>Razón negar: </label><br />
					<input type="text" name="reason" value="" />
                    </td>
                    <td valign="bottom" align="center" colspan="2">
                    <br />
                    <input type="submit"  value="Negar"/>
            		</td>
                 
                </tr><!-- END ROW -->
 <%else%>
<tr>
No Travel To approve
</tr> 
<%end if%>
            </table>
		                
           </fieldset><!-- END OF FADED -->
     
           </form>
           
        
    	</div><!-- END .main_wrapper_margin -->
	</div><!-- END #main_wrapper -->

         <!-- FOOTER -->
         
         <!--#INCLUDE FILE="costabaja_footer.asp"-->
         
         <!-- END FOOTER -->   

</body>
</html>
